<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>紧系联系人填写</title>
    <link rel="stylesheet" href="__STATIC__/index/css/weui.css"/>
    <link rel="stylesheet" href="__STATIC__/index/css/example.css"/>
    <script src="__STATIC__/index/js/jquery-1.11.3.js"></script>
    <script src="__STATIC__/index/js/jquery.js"></script>
    <script src="__STATIC__/index/layer/layer.js"></script>
    <style>
        .backg{
            background-image: url('__STATIC__/index/images/backg.png');
            background-size: 100% 200%;
        }
    </style>
</head>
<body class="backg">
<div style="width:90%;position:absolute;top: 7%;left: 50%;transform: translateX(-50%);" >
    <form action="urgentadd" method="post" name="form1" enctype="multipart/form-data">
        <div class="weui-cells" style="background-color:transparent;">
            <div class="weui-cell" style="background-color:transparent;">
                <div class="weui-cell__bd">
                    <input  class="weui-input" style="width: 90%" type="text" name="name1" id="name1" placeholder="紧急联系人1"><p style="color: red">*</p>
                </div>
            </div>
        </div>

    <form action="urgentadd" method="post" name="form1" enctype="multipart/form-data">
<div class="weui-cells" style="background-color:transparent;">
    <div class="weui-cell" style="background-color:transparent;">
        <div class="weui-cell__bd">
            <input  class="weui-input" style="width: 90%" type="text" name="emergencycontact1" id="emergencycontact1" placeholder="手机号"><p style="color: red">*</p>
        </div>
    </div>
</div>
<div class="weui-cell weui-cell_select weui-cell_select-after">
    <div class="weui-cell__hd">
        <label for="" class="weui-label" style="background-color: transparent;">关系</label>
    </div>
    <div class="weui-cell__bd">
        <select class="weui-select" name="relationship1" name="relationship1" id="relationship1"><p style="color: red">*</p>
            <option value="0" style="background-color: transparent;">请选择</option>
            <option value="1" style="background-color: transparent;">父母</option>
            <option value="2" style="background-color: transparent;">兄妹</option>
            <option value="3" style="background-color: transparent;">朋友</option>
            <option value="4" style="background-color: transparent;">同事</option>
        </select>
    </div>
</div>
        <div class="weui-cells" style="background-color:transparent;">
            <div class="weui-cell" style="background-color:transparent;">
                <div class="weui-cell__bd">
                    <input  class="weui-input" style="width: 90%" type="text" name="name2" id="name2" placeholder="紧急联系人2"><p style="color: red">*</p>
                </div>
            </div>
        </div>
    <div class="weui-cells" style="background-color:transparent;">
        <div class="weui-cell" style="background-color:transparent;">
            <div class="weui-cell__bd">
                <input  class="weui-input" style="width: 90%" type="text" name="emergencycontact2" id="emergencycontact2" placeholder="手机号"><p style="color: red">*</p>
            </div>
        </div>
    </div>
    <div class="weui-cell weui-cell_select weui-cell_select-after">
        <div class="weui-cell__hd">
            <label for="" class="weui-label" style="background-color: transparent;">关系</label>
        </div>
        <div class="weui-cell__bd">
            <select class="weui-select" name="relationship2" name="relationship2" id="relationship2"><p style="color: red">*</p>
                <option value="0" style="background-color: transparent;">请选择</option>
                <option value="1" style="background-color: transparent;">父母</option>
                <option value="2" style="background-color: transparent;">兄妹</option>
                <option value="3" style="background-color: transparent;">朋友</option>
                <option value="4" style="background-color: transparent;">同事</option>
            </select>
        </div>
    </div>
        <div class="weui-cells" style="background-color:transparent;">
            <div class="weui-cell">
                <div class="weui-cell__bd" style="background-color:transparent;">
                    <input  class="weui-input" style="width: 90%" type="text" name="name3" id="name3" placeholder="紧急联系人3"><p style="color: red">*</p>
                </div>
            </div>
        </div>
    <div class="weui-cells" style="background-color:transparent;" >
        <div class="weui-cell" style="background-color:transparent;">
            <div class="weui-cell__bd">
                <input  class="weui-input" style="width: 90%" type="text" name="emergencycontact3" id="emergencycontact3" placeholder="手机号"><p style="color: red">*</p>
            </div>
        </div>
    </div>
    <div class="weui-cell weui-cell_select weui-cell_select-after">
        <div class="weui-cell__hd">
            <label for="" class="weui-label" style="background-color: transparent;">关系</label>
        </div>
        <div class="weui-cell__bd">
            <select class="weui-select" name="relationship3" name="relationship3" id="relationship3"><p style="color: red">*</p>
                <option value="0" style="background-color: transparent;">请选择</option>
                <option value="1" style="background-color: transparent;">父母</option>
                <option value="2" style="background-color: transparent;">兄妹</option>
                <option value="3" style="background-color: transparent;">朋友</option>
                <option value="4" style="background-color: transparent;">同事</option>
            </select>
        </div>
    </div>
    </form>
    <br/>
    <br/>
    <a class="weui-btn weui-btn_primary" style="background: #265EC4;" id="showTooltips" onclick="add()" >提交</a>
</div>
</body>
<script>
    function add() {
         var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
        //var myreg = /^1([38]\d|5[0-35-9]|7[3678])\d{8}$/;
        var emergencycontact1 = $(" input[ name='emergencycontact1' ] ").val();
        var relationship1 = $(" input[ name='relationship1' ] ").val();
        if(!myreg.test(emergencycontact1)){layer.msg('手机号不正确');return false;}
        if(relationship1 == 0 ){layer.msg('请选择关系');return false;}
        var emergencycontact2 = $(" input[ name='emergencycontact2' ] ").val();
        var relationship2 = $(" input[ name='relationship2' ] ").val();
        if(relationship2 == 0 ){layer.msg('请选择关系');return false;}
        if(!myreg.test(emergencycontact2)){layer.msg('手机号不正确');return false;}
        var emergencycontact3 = $(" input[ name='emergencycontact3' ] ").val();
        var relationship3 = $(" input[ name='relationship3' ] ").val();
        if(relationship3 == 0 ){layer.msg('请选择关系');return false;}
        if(!myreg.test(emergencycontact3)){layer.msg('手机号不正确');return false;}
        if(emergencycontact1 ==emergencycontact2 && emergencycontact1 == emergencycontact3 && emergencycontact2 ==emergencycontact3){
            layer.msg('手机号不能重复');return false;
        }
        var name1 = $(" input[ name='name1' ] ").val();
        var name2 = $(" input[ name='name2' ] ").val();
        var name3 = $(" input[ name='name3' ] ").val();
        if(name1 == "" ){layer.msg('姓名不能为空');return false;}
        if(name2 == "" ){layer.msg('姓名不能为空');return false;}
        if(name3 == "" ){layer.msg('姓名不能为空');return false;}
        document.form1.submit();
    }
</script>
<script src="__STATIC__/index/js/mui.min.js"></script>
<script>
    function plusReady(){
        var old_back = mui.back;
        mui.back = function() {
            //alert('不关闭')
        }
    }
    if(window.plus){
        plusReady();
    }else{
        document.addEventListener("plusready",plusReady,false);
    }
</script>
</html>